package cn.edu.java.io.outputstream.filteroutputstream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class PrintStreamDemo {
    public static void main(String[] args) {
        // 创建PrintStream对象，并指定输出目标为文件
        PrintStream printStream = new PrintStream(System.out);

        // 向PrintStream写入数据
        printStream.println("Hello, PrintStream!");
        printStream.printf("This is a formatted message: %s\n", "Java IO");

        // 关闭PrintStream
        printStream.close();

        System.out.println("Data has been written to the file.");

    }
}
